﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using IHISCETeim.BLL;
using IHISCETeim.Library;
using IHISCETeim.Model;
namespace IHISCETeim.Web.MachineSys.PartsModel
{
    public partial class PartsRankEdit : PageBase
    {
        protected override string DWZRef
        {
            get
            {
                return "PartsRankList";
            }
        }

        protected int RID
        {
            get
            {
                return GetRequestValue<int>("RID", 0);
            }
        }
        protected string Action
        {
            get
            {
                return GetRequestValue<string>("Action", "add");
            }
        }

        protected PartsRankInfo _folderObj = null;
        protected PartsRankInfo folderObj
        {
            get
            {
                if (_folderObj == null)
                    _folderObj = PartsRankController.GetList(RID);

                return _folderObj;
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (GetRequestValue<string>("ajaxmethod", "") == "add")
            {
                addmenu();
            }

            if (GetRequestValue<string>("ajaxmethod", "") == "edit")
            {
                editmenu();
            }
        }

        private void addmenu()
        {
            PartsRankInfo obj = Request.SerializableObject<PartsRankInfo>();           

            int r = PartsRankController.Add(obj);

            if (r>0)
            {               
                SuccessJson("成功添加考核定级", this.DWZRef);
            }
            else
            {
                AlertJson("添加添加考核定级");
            }
        }

        private void editmenu()
        {
            PartsRankInfo obj = Request.SerializableObject<PartsRankInfo>();           

           
            bool r = PartsRankController.Update(obj);

            if (r)
            {                
                SuccessJson("成功修改考核定级信息");
            }
            else
            {
                AlertJson("修改考核定级信息失败");
            }
        }
    }
}